<!-- Page Content -->
<div class="container">
	<!-- Page Heading/Breadcrumbs -->
	<div class="row">
		<div class="col-lg-12">
			<h1 class="page-header">Lista de &Aacutelbuns</h1>
			<ol class="breadcrumb">
				<li><a href="index.php?pg=home">Home</a></li>
				<li class="active">&Aacutelbuns</li>
			</ol>
		</div>
	</div>
	<!-- /.row -->
<?php
	include "../admin/p_usuario/valida_credenciais.php";
	include_once '../admin/lib/config.inc.php';
	$valCr = new valida_credenciais();
	
	/*$nivel define o array de acessos, ou seja, os grupos que podem acessar essa pagina	
	$nivel = array(1,2);
	if(!($valCr->validar($nivel))){
	 	header('Location: index.php?pg=denied');
	}*/
	
	$max = 10; // define a quantidade de eventos a serem listados por pagina
	@$pagina = $_GET['pagina'];
	
	if(!$pagina){
		$inicio = 0;
		$pagina = 1;
	}else{
		$inicio = ($pagina - 1) * $max;
	}
	
	$resul = mysql_query("SELECT * FROM `albuns` WHERE `albuns`.`status` LIKE '1' ORDER BY `albuns`.`created` DESC");
	$num = mysql_num_rows($resul);
	
	if($num == 0){
		print "N&atildeo existem &Aacutelbuns cadastrados no sistema !";
	}else{
		$total_paginas = ceil($num/$max);
		
		$resul = mysql_query("SELECT * FROM `albuns` WHERE `albuns`.`status` LIKE '1' ORDER BY `albuns`.`created` DESC LIMIT ".$inicio.",".$max."");
		$num = mysql_num_rows($resul);
	}
?>

	<div class="row">
		<div class="col-md-3">
			<?php include "actions-album.php"; ?>
		</div><!-- end col md 3 -->

		<div class="col-md-9">
		<div class="panel panel-default">
			<div class="panel-heading"><h5>Rela&ccedil&atildeo de &Aacutelbuns cadastrados</h5></div>
				<div class="table-responsive">
			<table cellpadding="0" cellspacing="0" class="table table-bordered">
				<thead>
					<tr>
						<th width="90px">Cadastro</th>
						<th>Nome</th>
						<th>Descri&ccedil&atildeo</th>
						<th>Status</th>						
						<!-- <th>Data Modificado</th> -->
						<th class="actions">Op&ccedil&otildees</th>
					</tr>
				</thead>
				<tbody>
				<?php while ($album = mysql_fetch_array($resul)) {?>
					<tr>
						<td><?php echo date('d/m/Y', strtotime($album['created'])); ?>&nbsp;</td>
						<td><?php echo $album['nome_album']; ?>&nbsp;</td>
						<td><?php echo $album['descricao_album']?></td>
						<td><?php if ($album['status'] == 1) echo '&Aacutelbum Ativo'; else echo '&Aacutelbum Inativo !'; ?></td>
						<td class="actions">
							<?php include "actions-album-td.php";?>
						</td>
					</tr>
					
				<?php } ?>
				</tbody>
			</table>
			</div>
			
			<div class="panel-footer" style="text-align:center;">
			<?php //N�o deixai essa parte de acordo com o modelo para programa��o proposto pois teria muitos <?php, por isso optei por usar o print dentro do <?php
			print  "Temos ".$num."  &Aacutelbum(s) cadastrado(s) no sistema.";
			print " Listando a p&aacutegina ".$pagina." de ".@$total_paginas."!";
			print '</br>';
			if($pagina != 1){
				print '<a href="index.php?pg=albuns&i='. $_SERVER['QUERY_STRING']. "&pagina=".($pagina - 1).'"><< anterior</a>';
			}else{
				print '<span style="color: #ccc;"><< anterior </span>';
			}
					
			if (@$total_paginas > 1){
				for ($i=1; $i <= $total_paginas; $i++){
					if ($pagina == $i){
						echo "<span class='al'> [".$pagina."] </span>";
					}else{
						echo "<a href=\"index.php?pg=albuns&i=" . $_SERVER['QUERY_STRING']."&pagina=".$i."\">&nbsp;".$i."&nbsp;</a> ";
					}
				}
			}
					
			if($pagina < @$total_paginas){
				print '<a href="index.php?pg=albuns&i='. $_SERVER['QUERY_STRING']. "&pagina=".($pagina + 1).'">pr&oacutexima >></a>';
			}else{
				print '<span style="color: #ccc;"> pr&oacutexima >></span>';
			}  
			?>
			</div>
		</div>
		</div> <!-- end col md 9 -->
	</div><!-- end row -->
</div><!-- end containing of content -->